home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Mark Pilgrim / Pentominoes 1.4.1 / source / Pentominoes ƒ / Pent code / pent setup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-30  |  4.6 KB  |  221 lines  |  [TEXT/KAHL]

  1. /**********************************************************************\
  2.  
  3. File:        pent setup.c
  4.  
  5. Purpose:    This module handles calculations made at the beginning of
  6.             each new game, to determine how large the main window is.
  7.  
  8.  
  9. Pentominoes - a 2-D geometry board game
  10. Copyright (C) 1993 Mark Pilgrim
  11.  
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program in a file named "GNU General Public License".
  24. If not, write to the Free Software Foundation, 675 Mass Ave,
  25. Cambridge, MA 02139, USA.
  26.  
  27. \**********************************************************************/
  28.  
  29. #include "pent setup.h"
  30. #include "pent.h"
  31. #include "pent load-save.h"
  32. #include "msg sounds.h"
  33. #include "msg graphics.h"
  34. #include "msg menus.h"
  35.  
  36. void CalculateRowsandCols(void)
  37. {
  38.     switch (gWhichBoard)
  39.     {
  40.         case 1:
  41.         case 2:
  42.         case 3:
  43.         case 4:
  44.         case 5:
  45.         case 10:
  46.         case 11:
  47.         case 12:
  48.         case 13:
  49.             gNumRows=gNumCols=8;
  50.             break;
  51.         case 6:
  52.             gNumRows=6;
  53.             gNumCols=10;
  54.             break;
  55.         case 7:
  56.             gNumRows=5;
  57.             gNumCols=12;
  58.             break;
  59.         case 8:
  60.             gNumRows=4;
  61.             gNumCols=15;
  62.             break;
  63.         case 9:
  64.             gNumRows=3;
  65.             gNumCols=20;
  66.             break;
  67.         case 14:
  68.         case 15:
  69.         case 16:
  70.         case 17:
  71.         case 18:
  72.         case 19:
  73.         case 20:
  74.         case 21:
  75.         case 22:
  76.         case 23:
  77.         case 24:
  78.         case 25:
  79.         case 30:
  80.             gNumRows=5;
  81.             gNumCols=13;
  82.             break;
  83.         case 26:
  84.         case 27:
  85.             gNumRows=8;
  86.             gNumCols=9;
  87.             break;
  88.         case 28:
  89.             gNumRows=7;
  90.             gNumCols=10;
  91.             break;
  92.         case 29:
  93.             gNumRows=6;
  94.             gNumCols=15;
  95.             break;
  96.         case 31:
  97.             gNumRows=4;
  98.             gNumCols=16;
  99.             break;
  100.     }
  101. }
  102.  
  103. void InitGameVariables(void)
  104. {
  105.     int            i,j;
  106.     
  107.     gWindowWidth = (gNumCols*25) + 10;
  108.     gWindowHeight = (gNumRows*25) + 95;
  109.     
  110.     for (i=0; i<gNumRows; i++)
  111.         for (j=0; j<gNumCols; j++)
  112.             Board[i][j] = -1;
  113.     
  114.     for (i=0; i<12; i++)
  115.         PieceUsed[i] = FALSE;
  116.     
  117.     switch (gWhichBoard)
  118.     {
  119.         case 2:
  120.             Board[0][0]=Board[0][7]=Board[7][0]=Board[7][7]=12;
  121.             break;
  122.         case 3:
  123.             Board[3][3]=Board[4][3]=Board[3][4]=Board[4][4]=12;
  124.             break;
  125.         case 4:
  126.             Board[1][1]=Board[6][6]=Board[1][6]=Board[6][1]=12;
  127.             break;
  128.         case 5:
  129.             Board[2][3]=Board[3][5]=Board[4][2]=Board[5][4]=12;
  130.             break;
  131.         case 10:
  132.             Board[7][7]=Board[7][6]=Board[6][7]=Board[6][6]=12;
  133.             break;
  134.         case 11:
  135.             Board[3][5]=Board[3][6]=Board[4][5]=Board[4][6]=12;
  136.             break;
  137.         case 12:
  138.             Board[0][4]=Board[3][0]=Board[4][7]=Board[7][3]=12;
  139.             break;
  140.         case 13:
  141.             Board[2][2]=Board[2][5]=Board[5][2]=Board[5][5]=12;
  142.             break;
  143.         case 14:
  144.             Board[0][6]=Board[1][6]=Board[2][6]=Board[3][6]=Board[4][6]=12;
  145.             break;
  146.         case 15:
  147.             Board[0][6]=Board[1][6]=Board[2][6]=Board[3][6]=Board[3][7]=12;
  148.             break;
  149.         case 16:
  150.             Board[1][5]=Board[2][5]=Board[3][5]=Board[3][6]=Board[3][7]=12;
  151.             break;
  152.         case 17:
  153.             Board[1][6]=Board[2][5]=Board[2][6]=Board[2][7]=Board[3][6]=12;
  154.             break;
  155.         case 18:
  156.             Board[1][6]=Board[1][7]=Board[2][6]=Board[2][7]=Board[3][6]=12;
  157.             break;
  158.         case 19:
  159.             Board[1][5]=Board[2][5]=Board[2][6]=Board[3][6]=Board[3][7]=12;
  160.             break;
  161.         case 20:
  162.             Board[1][6]=Board[1][7]=Board[2][6]=Board[3][6]=Board[3][7]=12;
  163.             break;
  164.         case 21:
  165.             Board[1][6]=Board[1][7]=Board[2][6]=Board[3][5]=Board[3][6]=12;
  166.             break;
  167.         case 22:
  168.             Board[0][6]=Board[1][6]=Board[2][6]=Board[2][7]=Board[3][6]=12;
  169.             break;
  170.         case 23:
  171.             Board[1][6]=Board[1][7]=Board[2][5]=Board[2][6]=Board[3][6]=12;
  172.             break;
  173.         case 24:
  174.             Board[1][5]=Board[1][6]=Board[1][7]=Board[2][6]=Board[3][6]=12;
  175.             break;
  176.         case 25:
  177.             Board[0][6]=Board[1][6]=Board[2][6]=Board[2][7]=Board[3][7]=12;
  178.             break;
  179.         case 26:
  180.             for (i=2; i<=5; i++)
  181.                 for (j=3; j<=5; j++)
  182.                     Board[i][j]=12;
  183.             break;
  184.         case 27:
  185.             Board[3][3]=Board[3][5]=Board[4][3]=Board[4][5]=12;
  186.             for (i=0; i<=7; i++)
  187.                 Board[i][4]=12;
  188.             break;
  189.         case 28:
  190.             for (i=1; i<=5; i++)
  191.                 Board[i][0]=Board[i][9]=12;
  192.             break;
  193.         case 29:
  194.             for (i=1; i<=5; i++)
  195.                 for (j=0; j<i; j++)
  196.                     Board[i][j]=Board[5-i][14-j]=12;
  197.             break;
  198.         case 30:
  199.             for (i=0; i<5; i++)
  200.                 Board[i][3]=12;
  201.             break;
  202.         case 31:
  203.             for (i=0; i<4; i++)
  204.                 Board[i][5]=12;
  205.             break;
  206.     }
  207.     
  208.     gNumHilited = 0;
  209.     gNumPlayed = 0;
  210.     gameFile.name[0]=0x00;
  211. }
  212.  
  213. void OpenNewGame(void)
  214. {
  215.     gCurrentColor=-2;
  216.     DoSound(sound_startgame);
  217.     OpenMainWindow();
  218.     AdjustMenus();
  219.     DrawMenuBar();
  220. }
  221.